package sapling.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by Administrator on 2017/6/30.
 */
public class LetterUtil {
    public static String next(String s) {
        String[] array = new String[] { "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "O", "P", "Q",
                "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
        for (int i = 0; i < array.length; i++) {
            if (s.equals("Z")) {
                return "ZA";
            }
            if (s.equals(array[i])) {
                return array[++i];
            }
        }
        return s;
    }

    public static String cutOut(String s) {
        if("".equals(s)){
            s="A";
        }
        String front="";
        String result="";
        if (1 == s.length()) {
            result= next(s);
        } else if (0 == s.length()) {
            result= "A";
        } else if (1 < s.length()) {
            front=s.substring(0,s.length()-1);
            result=front+ next(s.substring(s.length()-1));
        }
        return result;
    }

    public static Boolean chinese(String args) {
        boolean temp = false;
        Pattern p=Pattern.compile("[\u4e00-\u9fa5]");
        Matcher m=p.matcher(args);
        if(m.find()){
            temp =  true;
        }
        return temp;
    }

}
